#include <assert.h>

#include "headers.h"

scm make_header(hdr_color col, scm raw_size, scm scm_size) {
  assert(0 <= raw_size);
  assert(raw_size <= 0xFFFFFF);
  assert(0 <= scm_size);
  assert(scm_size <= 0xFFFFFF);

  return
    (scm_size << (24 + 3)) |
    (raw_size << 3) |
    col;
}

scm header_color(scm hdr) {
  return hdr & 0b111;
}

scm header_raw_size(scm hdr) {
  return (hdr >> 3) & 0xFFFFFF;
}

scm header_scm_size(scm hdr) {
  return (hdr >> (24 + 3)) & 0xFFFFFF;
}

scm color_header(scm hdr, hdr_color col) {
  hdr &= ~0b111;
  hdr |= col;
  return hdr;
}
